package 剑指offerII;

public class _05单词长度的最大乘积 {
    public int maxProduct(String[] words) {
        int len = words.length,res = 0;
        int[] nums = new int[len];
        for(int i = 0; i < len ; i++){
            String word = words[i];
            int len2 = word.length();
            for(int j = 0; j < len2; j++){
                nums[i] |= 1 << (word.charAt(j) - 'a');
            }
        }
        for(int i = 0; i < nums.length; i++){
            for(int j = i + 1; j < nums.length; j++){
                if((nums[i] & nums[j]) == 0){
                    res = Math.max(res,words[i].length() * words[j].length());
                }
            }
        }
        return res;
    }
}
